<style scoped>
  .sellform >>> .weui-form-preview__hd .weui-form-preview__value {
    font-size: 1.2em;
    padding-right: 20px;
  }
  .sellform {
    background: #e3e3e3;
  }
  .page-infinite-wrapper {
    background: #e3e3e3;
  }
  .weui-form-preview {
    margin: 5px;
    border-radius: 5px;
  }

  .rj-cell-child {
    display: inline-block;
    font-size: 0;
    padding: 5px 15px;
    text-align: left;
  }
  .rj-cell-child.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell-child.minpad{
    padding-right: 10px !important;
  }
  .rj-cell-child label {
    color: #333;
    font-size: 13px;
  }
  .rj-cell-child span {
    padding-left: 20px;
    font-size: 13px;
    color: #333;
  }
  .rj-cell-child .tip {
    font-size: 16px;
    color: #333;
  }
  .rj-cell-child i {
    font-size: 18px;
    font-style: normal;
    color: #333;
  }
  .rj-cell-child-tit {
    background: #eee;
    font-size: 14px;
    padding: 5px 15px;
    border-bottom: 1px solid #ddd;
  }
  .weui-form-preview__ft .weui-form-preview {
    background: #f5f5ef;
  }
  .weui-form-preview__ft {
    line-height: normal;
  }



  .weui_tab_bd {
    background: #eee;
  }
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui_navbar {
    white-space: nowrap;
    overflow: scroll;
    display: block !important;
    border-bottom: 1px solid #BCBAB6;
    font-size: 0;
    /*background: #fafafa;*/
  }
  .weui_navbar_item {
    font-size: 14px;
    display: inline-block;
    width: 20%;
    padding: 13px 0;
    background: #fff;
    position: relative;
    color: #888;
  }
  .weui_navbar:after {
    border-bottom: 0;
  }
  .weui_navbar_item:after {
    content: " ";
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    border-right: 1px solid #cccccc;
    color: #cccccc;
    -webkit-transform-origin: 100% 0;
    transform-origin: 100% 0;
    -webkit-transform: scaleX(0.5);
    transform: scaleX(0.5);
    font-size: 10px;
  }
  .weui-panel__bd {
    text-align: left;
  }
  .hoverbar {
    background: #03A9F4;
    position: fixed;
    bottom: 100px;
    right: 20px;
    height: 50px;
    line-height: 50px;
    width: 50px;
    z-index: 100;
    font-size: 30px;
    border-radius: 50%;
    box-shadow: 0px 2px 3px rgba(100, 100, 100, 0.5);
    color: #fff;
  }
  .rj-label {
    display: inline-block;
  }
  .rj-value {
    display: inline-block;
    padding-left: 5px;
  }

  .weui-form-preview {
    font-size: 14px;
    position: relative;
  }
  .weui-form-preview__btn {
    line-height: 50px;
  }
  .btarr {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background: #fcfcfc;
    box-shadow: 0px 2px 4px rgba(100, 100, 100, 0.5);
    color: #333;
    text-align: center;
    font-size: 0;
    border-radius: 0 0 10px 10px;
  }
  .rj-btmarr {
    transform: rotate(90deg);
    font-size: 30px;
    color: #0bb20c;
    margin: 0 auto;
    margin-left: 3px;
    height: 46px;
  }
  .rj-btmarr2 {
    transform: rotate(-90deg);
    font-size: 30px;
    color: #0bb20c;
    margin: 0 auto;
    margin-right: 3px;
  }
  .short .rj-cell-child span {
    padding-left: 5px;
  }
</style>
<template>
  <div>
    <div v-show="showFull" class="weui-form-preview">
      <div class="weui-form-preview__hd" @click="viewItem(item.id)">
        <label class="weui-form-preview__label">订单编号</label>
        <em class="weui-form-preview__value">{{item.sellcode}}</em>
      </div>
      <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">项目</label>
          <span class="weui-form-preview__value">{{item.projName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">申请人</label>
          <span class="weui-form-preview__value">{{item.applyname}}[{{item.depname}}]</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">销售组织</label>
          <span class="weui-form-preview__value">{{item.orgName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">客户</label>
          <span class="weui-form-preview__value">{{item.customername}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">付款方式</label>
          <span class="weui-form-preview__value">{{item.paytypename}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">订单类型</label>
          <span class="weui-form-preview__value">{{item.flagname}}{{mainCode(item.partitionflag, item.parentcode)}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="item.strmName">
          <label class="weui-form-preview__label">出库库房</label>
          <span class="weui-form-preview__value">{{item.strmName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">货品类型</label>
          <span class="weui-form-preview__value">{{item.quitSRTypeName}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="flowid == 36 && item.faretypename">
          <label class="weui-form-preview__label">物流结算</label>
          <span class="weui-form-preview__value">{{item.faretypename}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">配送方式</label>
          <span class="weui-form-preview__value">{{item.deliverytypename}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="item.carcode">
          <label class="weui-form-preview__label">车牌号</label>
          <span class="weui-form-preview__value">{{item.carcode}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="item.drivername">
          <label class="weui-form-preview__label">司机姓名</label>
          <span class="weui-form-preview__value">{{item.drivername}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="item.driverphone">
          <label class="weui-form-preview__label">司机电话</label>
          <span class="weui-form-preview__value">{{item.driverphone}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">要求发货日期</label>
          <span class="weui-form-preview__value">{{item.senddate}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">要求到货日期</label>
          <span class="weui-form-preview__value">{{item.arrivedate}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">订单重量</label>
          <span class="weui-form-preview__value">{{item.orderweight}} 吨</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">状态</label>
          <span class="weui-form-preview__value">{{item.statusname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">备注</label>
          <span class="weui-form-preview__value" style="color: #000;">{{item.remarks}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">创建时间</label>
          <span class="weui-form-preview__value">{{item.createtime}}</span>
        </div>
      </div>
      <div class="weui-form-preview__ft olist">
        <!--                <div class="weui-panel__hd"></div>-->
        <div class="weui-panel__bd">
          <div class="weui-form-preview" v-for="(product, index) in allItems" :key="product.guid">
            <div class="rj-cell-child-tit">产品明细 {{index+1}}</div>
            <div class="rj-cell-child">
              <label>品&nbsp;&nbsp;&nbsp;种：</label><span>{{product.productname}}</span> <span>{{product.spname}} </span>
            </div>
            <div class="rj-cell-child">
              <label>订单数量：</label><span>{{product.flag == 2 ? product.orderpack : product.weight}} {{product.unit}}</span>
            </div>
            <div class="rj-cell-child" v-if="checkNull(product.handselcount)">
              <label>赠送数量：</label><span>{{product.handselcount}} {{product.unit}}</span>
            </div>
            <div class="rj-cell-child" v-show="showPrice">>
              <label>单&nbsp;&nbsp;&nbsp;价：</label><span>{{product.price}} {{packUnit(product.unit, item.currency)}}</span><span></span>
            </div>
            <div class="rj-cell-child">
              <label>备&nbsp;&nbsp;&nbsp;注：</label><span>{{product.remark}}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="weui-form-preview__ft">
        <template v-for="(node, nodeIndex) in item.nodes">
          <a class="weui-form-preview__btn weui-form-preview__btn_primary" v-for="(node, index) in item.nodes" :key="node.guid" href="javascript:" @click="doAct(node.operate, item.id, node.flowTaskId, node.name, node.annex, node.refuseFlag)" >{{node.name}}</a>
        </template>
      </div>
      <div class="btarr" @click="showFull = false">
        <p class="rj-btmarr2">&raquo;</p>
      </div>
    </div>
    <div v-show="!showFull" class="weui-form-preview short" style="font-size: 14px;color: #333;">
      <div class="weui-form-preview__bd" @click="viewItem(item.id)" style="text-align: left;color: #333;">
        <div>
          <label class="rj-label">订单编号:</label>
          <div class="rj-value">{{item.sellcode}}</div>
          <label class="rj-label" style="margin-left: 5px;">状态:</label>
          <div class="rj-value">{{item.statusname}}</div>
        </div>
        <div>
          <label class="rj-label">客户:</label>
          <div class="rj-value">{{item.customername}}</div>
          <label class="rj-label" style="margin-left: 5px;">申请时间:</label>
          <div class="rj-value">{{item.createtime.substr(0, 10)}}</div>
        </div>
        <div>
          <label class="rj-label">申请人:</label>
          <div class="rj-value">{{item.applyname}}[{{item.depname}}]</div>
        </div>
      </div>
      <div class="weui-form-preview__ft olist">
        <div class="weui-panel__bd">
          <div class="weui-form-preview" style="font-size: 14px;" v-for="(product, index) in allItems" v-if="index < 2" :key="product.guid">
            <div class="rj-cell-child">
              <label>产品：</label><span>{{product.productname}}</span> <span>{{product.spname}} </span>
            </div>
<!--            <div class="rj-cell-child" v-if="item.settletype == 1">-->
<!--              <label>订单件数：</label><span>{{product.orderpack}} {{product.unit}}</span>-->
<!--            </div>-->
            <div class="rj-cell-child">
              <label>订单数量：</label><span>{{product.flag == 2 ? product.orderpack : product.weight}} {{product.unit}}</span>
            </div>
<!--            <div class="rj-cell-child" v-show="showPrice">-->
<!--              <label>单价：</label><span>{{product.price}} {{packUnit(product.unit, item.currency)}}</span><span></span>-->
<!--            </div>-->
          </div>
        </div>
      </div>
      <div class="weui-form-preview__ft">
          <a class="weui-form-preview__btn weui-form-preview__btn_primary" v-for="(node, index) in item.nodes" :key="node.guid" href="javascript:" @click="doAct(node.operate, item.id, node.flowTaskId, node.name, node.annex, node.refuseflag)" >{{node.name}}</a>
      </div>
      <div class="btarr" @click="showFull = true">
        <p class="rj-btmarr">&raquo;</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SellformItem',
  data () {
    return {
      OUTCOUNT: 2000,
      showFull: false,
    }
  },
  props: [
    'data',
    'item',
    'index',
    'permissions',
    'showPrice',
    'pstat',
    'flowid'
  ],
  computed: {
    payUnit: function () {
      return this.settletype == 1 ? '元/件' : '元/吨';
    },
    allItems: function () {
      if (this.item.spitems) {
        return this.item.spitems.concat(this.item.items);
      } else {
        this.item.items;
      }
    }
  },
  created() {
  },
  mounted() {
  },
  watch: {

  },
  methods: {
    delIt: function (id){
      let that = this;
      $.confirm("确定删除?", function() {
        that.axios({
          method: 'post',
          url: '/prod-api/bill/sellform/del',
          params: {id: id}
        }).then((response) => {
          if (response.data.code == 200) {
            that.$emit('getPageData');
            that.toastSuccess('删除成功！');
          } else if (response.data.msg) {
            that.toastText(response.data.msg);
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            that.toastError("系统错误");
          }
        })
      })
    },
    mainCode: function(flag, code) {
      if (flag == 3 || flag == 4) {
        return '[' + code + ']';
      }
    },
    //在下一单
    NextOeder(row) {
      this.$router.push({
        path:'/sellform/next',
        query:{
          sellformid:row
        }
      })
    },
    packUnit: function(unit, currency) {
      return unit != undefined && unit != '' ? currency == 2 ? '美元/' + unit : '元/' + unit : '';
    },
    viewItem: function (id) {
      $('#searchInput').val('');
      this.$router.push({name: 'ViewSellform2', query: {id: id, flowid: this.flowid}});
    },
    doAct: async function (name, id, nodeid, actname, annex, refuseflag) {
      let that = this;
      let acts = this.$store.state.acts;
      if (name == 'delete36') {
        that.delIt(id);
      } else if (name == 'dispatch34') {
        that.$router.push({name: acts[name], query: {id:id, nodeid: nodeid, title: actname, annex: annex, refuseflag: refuseflag, partitiontype: 1, flowid: this.flowid}});
      } else if (name == 'dispatch35') {
        that.$router.push({name: acts[name], query: {id:id, nodeid: nodeid, title: actname, annex: annex, refuseflag: refuseflag, partitiontype: 1, flowid: this.flowid}});
      } else if (name == 'dispatch36') {
        that.$router.push({name: acts[name], query: {id:id, nodeid: nodeid, title: actname, annex: annex, refuseflag: refuseflag, partitiontype: 1, flowid: this.flowid}});
      } else {
        that.$router.push({name: acts[name], query: {id:id, nodeid: nodeid, title: actname, annex: annex, refuseflag: refuseflag, flowid: this.flowid}});
      }
    },
  }
}
</script>
